package com.wnzt.baszh.OCR;

import java.io.File;  
import java.io.IOException;  

import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import com.wnzt.baszh.OCR.OCR;  
  
public class OcrTest {
	public static void main(String[] args) {  
        String path = "E:\\img\\3.jpg";       
        System.out.println("ORC Test Begin......");  
        File file=new File(path);
       /* try {       
        	
            String valCode = new OCR().recognizeText(file, "jpg");   
            
            System.out.println(valCode);       
        } catch (IOException e) {       
            e.printStackTrace();       
        } catch (Exception e) {    
            e.printStackTrace();    
        } */        
        
        String recognizeText=null;
		try {
			recognizeText = new OCRUtil().recognizeText(file, "jpg");
			 System.out.print(recognizeText+"\t");
		} catch (Exception e) {
			e.printStackTrace();
		}  
       
		System.out.println("ORC Test End......");  
		
			File imageFile = new File("E:/img/2.jpg");  
	       //Tesseract tessreact = new Tesseract();  
	       Tesseract tessreact = Tesseract.getInstance();  
	       tessreact.setDatapath("D:/Tesseract-OCR");  
	       tessreact.setLanguage("chi_sim");
	       try {  
	           String result = tessreact.doOCR(imageFile);  
	           System.out.println(result);  
	       } catch (TesseractException e) {  
	           System.err.println(e.getMessage());  
	       }  
        
    } 
}
